package java51.lesson0529;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Teacher {
	String name = "刘老师";
	String school = "合肥科海";
	static int age;

	public static void main(String[] args) {
		Teacher te = new Teacher();
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入老师年龄");
		try {
			int ag = sc.nextInt();
			te.getAge(ag);
			age = ag;
			te.selfIntro();
			te.giveLession();
		} catch (InputMismatchException e) {
			System.err.println("输入错误！！");
			e.printStackTrace();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}

	public void selfIntro() {
		System.out.println("大家好，我今年" + age + "岁" + "是来自" + school + "的" + name);

	}

	public void giveLession() {
		System.out.println("打开eclipse");
		System.out.println("知识点讲解");
		System.out.println("总结提问！");
	}

	public int getAge(int a) throws Exception {
		if (a > 22) {
			return a;
		} else {
			throw new Exception("年龄不能小于22岁");
		}
	}
}
